package shun.demo.remote.touch.model;

import android.view.MotionEvent;

import java.io.Serializable;

/**
 * Created by chen on 14-4-26.
 */
public class MyMotionEvent implements Serializable {

    private static final long serialVersionUID = 1L;

    private long mDownTime;
    private long mEventTime;
    private int mAction;
    private float mX;
    private float mY;
    private int mSource;

    public long getDownTime() {
        return mDownTime;
    }

    public void setDownTime(long downTime) {
        mDownTime = downTime;
    }

    public long getEventTime() {
        return mEventTime;
    }

    public void setEventTime(long eventTime) {
        mEventTime = eventTime;
    }

    public int getAction() {
        return mAction;
    }

    public void setAction(int action) {
        mAction = action;
    }

    public float getX() {
        return mX;
    }

    public void setX(float x) {
        mX = x;
    }

    public float getY() {
        return mY;
    }

    public void setY(float y) {
        mY = y;
    }

    public int getSource() {
        return mSource;
    }

    public void setSource(int source) {
        mSource = source;
    }

    public void fromMotionEvent(MotionEvent motionEvent) {
        mDownTime = motionEvent.getDownTime();
        mEventTime = motionEvent.getEventTime();
        mAction = motionEvent.getAction();
        mX = motionEvent.getX();
        mY = motionEvent.getY();
        mSource = motionEvent.getSource();
    }

    public MotionEvent toMotionEvent() {
        MotionEvent motionEvent = MotionEvent.obtain(mDownTime, mEventTime, mAction, mX, mY, 0);
        motionEvent.setSource(mSource);
        return motionEvent;
    }
}
